package webbandidong.model;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

@Entity
@Table(name = "tbl_customer", uniqueConstraints = {@UniqueConstraint(columnNames = "customer_email")})
public class Customer implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "customer_id", nullable = false, unique = true)
    private int id;

    @Column(name = "customer_name", length = 200, nullable = false)
    private String name;

    @Column(name = "customer_address", length = 500, nullable = false)
    private String address;

    @Column(name = "customer_phone_number", length = 50, nullable = false)
    private String phoneNumber;

    @Column(name = "customer_email", length = 200)
    private String email;

    @Column(name = "customer_password", length = 200)
    private String password;

    @Column(name = "customer_account_number", length = 200)
    private String accountNumber;

    @OneToMany(mappedBy = "customer", fetch = FetchType.LAZY, cascade = CascadeType.ALL)
    private Set<Order> orders = new HashSet<Order>();

    public Customer() {

    }

    public Customer(int id, String name, String address, String phoneNumber, String email,
            String password, String accountNumber) {
        this.id = id;
        this.name = name;
        this.address = address;
        this.phoneNumber = phoneNumber;
        this.email = email;
        this.password = password;
        this.accountNumber = accountNumber;
    }

    public Customer(int id, String name, String address, String phoneNumber, String email,
            String password, String accountNumber, Set<Order> orders) {
        this(id, name, address, phoneNumber, email, password, accountNumber);
        this.orders = orders;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getPhoneNumber() {
        return phoneNumber;
    }

    public void setPhoneNumber(String phoneNumber) {
        this.phoneNumber = phoneNumber;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getAccountNumber() {
        return accountNumber;
    }

    public void setAccountNumber(String accountNumber) {
        this.accountNumber = accountNumber;
    }

    public Set<Order> getOrders() {
        return orders;
    }

    public void setOrders(Set<Order> orders) {
        this.orders = orders;
    }
}
